<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML>
<html>
  <head> 
	<%@ include file="/platform/style.jsp"%>
	<link rel='stylesheet' type='text/css' href='${ctx}/plugins/jquery-gridly/jquery.gridly.css'>
	<script type="text/javascript" src="${ctx}/plugins/jquery-gridly/jquery.gridly.js"></script>
	<script type="text/javascript" src="${ctx}/plugins/plupload2/plupload.full.min.js"></script>
	<script type="text/javascript" src="${ctx}/plugins/oss/upload.js"></script>
	<link rel="stylesheet" href="${ctx}/plugins/kindeditor/themes/default/default.css" />
	<script charset="utf-8" src="${ctx}/plugins/kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="${ctx}/plugins/kindeditor/lang/zh_CN.js"></script>

	<style>
		.status1{color:red;}
		.status2{color:#1C84C6;}
		.card_body{border:1px solid #DDDDDD;border-radius:3px;width:80%;padding:0 0 20px 0}
		.clasnav li{float:left;margin-right:10px;}
		.clasnav li span{float:right;margin-left:10px;}
		.pitem_sel{min-width:200px;}
		.pl_upimgdiv{position: relative;}
		.pl_upimgdiv .progresstxt{display:none;width:100%;height:12px;line-height:12px;text-align:center;font-size:10px;color:red;position: absolute;bottom:0px;}
		.pl_upimgdiv .progressbg{width:0;position:absolute;background:#00CD26;bottom:0px;height:12px;font-size:0px;}
		.pl_upimgdiv .remove{position:absolute;top:2px;right:2px;display:block;width:15px;height:15px;background:url(${ctx}/plugins/plupload2/filedel.jpg);}
  	
	</style>
	<script>
	function query(){
		$w.execForm({form:$('#queryForm'),target:$('#tbpanel'),pageNum:1})
	}
	function addProduct(){
		detail_editor=undefined,book_editor=undefined,aboutus_editor=undefined;
		$w.openDialog({url:ctx+'/webadmin/product/productAdd_selClass.jsp',title:"添加商品",w:700,h:450,maximized:true,afterClose:function(re){
			if(re){
				query();
			}
		}});
	}
	function editProduct(id){
		detail_editor=undefined,book_editor=undefined,aboutus_editor=undefined;
		$w.openDialog({url:ctx+'/products/ProductPage@show.page?bean.id='+id,title:"编辑商品",w:700,h:450,frame:true,maximized:true,afterClose:function(re){
			if(re){
				query();
			}
		}});
	}
	function delProduct(id){
		window.parent.$w.confirmMsg("确定删除？", function(r){
			if(r){
				$w.doUrl(ctx+"/products/ProductPage@del.page?bean.id="+id,{},function(json){
					query();
				})
			}
		})
	}
	function showProduct(id){
		$w.openDialog({url:ctx+'/products/ProductPage@show.page?bean.edit=false&bean.id='+id,title:"查看商品",w:700,h:450,maximized:true,afterClose:function(re){
			
		}});
	}
	function shelves(){
		var num=0;
		$("[name='primaryKey_']").each(function(){
			if(this.checked){
				num++;
				return false;
			}
		})
		if(num==0){
			window.parent.$w.infoMsg("请选择商品");return;
		}
		window.parent.$w.confirmMsg("确定上架选中商品？", function(r){
			if(r){
				$w.doUrl(ctx+"/products/ProductPage@shelves.page",$("#dataForm").serializeArray(),function(json){
					query();
				})
			}
		})
	}
	function offshelf(){
		var num=0;
		$("[name='primaryKey_']").each(function(){
			if(this.checked){
				num++;
				return false;
			}
		})
		if(num==0){
			window.parent.$w.infoMsg("请选择商品");return;
		}
		window.parent.$w.confirmMsg("确定下架选中商品？", function(r){
			if(r){
				$w.doUrl(ctx+"/products/ProductPage@offshelf.page",$("#dataForm").serializeArray(),function(json){
					query();
				})
			}
		})
	}
	var keditor;
	var detail_editor,book_editor,aboutus_editor;
	KindEditor.ready(function(K) {
		keditor=K;
	})
	</script>
  </head>
  
  <body class="easyui-layout">
	<div data-options="region:'center'" class="bodybg">
		<!-- 查询区域 -->
		<div class="easyui-panel ui-queryBar" border="false" data-options="doSize:false">
			<form id="queryForm" action="/products/ProductPage@productList.page" method="post">
			<w:hidden bind="pageNum"/>
			<w:hidden bind="pageSize_"/>
			<table cellpadding="0" cellspacing="0" style="margin-top:5px">
				<tr>
					<td width="60" align="right">编号：</td><td><w:text bind="bean.code" style="width:90px;"/></td>
					<td width="60" align="right">名称：</td><td><w:text bind="bean.name" style="width:110px;"/></td>
					<td width="90" align="right">生产厂家：</td><td><w:text bind="bean.company" style="width:110px;"/></td>
					<td width="60" align="right">分类：</td><td><select id="classtree" name="bean.classid" class="easyui-combotree" style="width:250px;height:28px;" data-options="url:'<%=path %>/products/ProductClassPage@loadClassTree2.page'"></select></td>
					<td width="50" align="right">状态：</td><td><select name="bean.status"><option value="">全部</option><option value="0">待上架</option><option value="1">已下架</option><option value="2">已上架</option></select></td>
					<td>
						&nbsp;<a href="javascript:;" class="easyui-linkbutton" iconCls="icon_search" onclick="query()">查询</a>
					</td>
				</tr>
			</table>
			</form>
		</div>
		<div class="easyui-panel ui-toolBar" border="false" data-options="doSize:false">
			<%--<a href="javascript:;" class="easyui-linkbutton" plain="true" onclick="addProduct()">添加商品</a>--%>
			<a href="javascript:;" class="easyui-linkbutton" plain="true" onclick="shelves()" style="width:50px;">上架</a>
			<a href="javascript:;" class="easyui-linkbutton" plain="true" onclick="offshelf()" style="width:50px;">下架</a>
		</div>
		<div class="ui_line" style="margin-top:10px"></div>
		<!-- 数据列表区域 -->
		<div id="tbpanel" class="easyui-panel" data-options="href:'<%=path %>/products/ProductPage@productList.page'">
		
		</div>
		
	</div>
	
  </body>
</html>
